package sfx;

import java.io.File;
import java.util.ArrayList;

/**
 * Used as an Interface to the Sound-class.
 * @author nick-luca.frank
 *
 */
public class SoundManager{
	private ArrayList<Sound> sound;
	
	//Sound-ID's
	public static final int TANKFIRE = 0;
	public static final int ENGINE = 1;
	public static final int IDLE_ENGINE = 2;
	public static final int CRASH = 3;
	public static final int WTFBOOM = 4;
	public static final int EXPLOSION = 5;
	public static final int IMPACT = 6;
	
	/**
	 * Loads the sound-files and opens them.
	 */
	public SoundManager(){
		sound = new ArrayList<Sound>();
		
		sound.add(new Sound(new File("res/sfx/tankfire.wav")));
		sound.add(new Sound(new File("res/sfx/engine.wav")));
		sound.add(new Sound(new File("res/sfx/engine_idle.wav")));
		sound.add(new Sound(new File("res/sfx/crash.wav")));
		sound.add(new Sound(new File("res/sfx/wtfboom.wav")));
		sound.add(new Sound(new File("res/sfx/explosion.wav")));
		sound.add(new Sound(new File("res/sfx/impact.wav")));
		
		for(int i = 0;i < sound.size();i++){
			sound.get(i).open();
		}
	}
	
	public Sound getSound(int sound){
		return this.sound.get(sound);
	}
	
	/**
	 * Plays a sound.
	 * @param sound ID of the sound to play
	 */
	public void play(int sound){
		this.sound.get(sound).play();
	}
	
	/**
	 * Stops a sound.
	 * @param sound ID of the sound to stop
	 */
	public void stop(int sound){
		this.sound.get(sound).stop();
	}
	
	public boolean isPlaying(int sound){
		return true;
	}
}